package com.study.framework.database;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;

public class DaoImpl extends SqlSessionDaoSupport implements Dao{

	public void setSuperSessionFactory(SqlSessionFactory sqlSessionFactory) {
		super.setSqlSessionFactory(sqlSessionFactory);
	}
	
	/**
	 * 여러행 조회시 사용
	 */
	public Object selectList(String map, String id, Object condition) {
		Object obj = getSqlSession().selectList(map + "." + id, condition);
		return obj;
	}

	/**
	 * 단일조회(예를들면 count라든가 1개의 row만 조회할때) 사
	 */
	public Object selectOne(String map, String id, Object condition) {
		Object obj = getSqlSession().selectOne(map + "." + id, condition);
		return obj;
	}

	/**
	 * update 문 사용
	 */
	public int update(String map, String id, Object condition) {
		int i = getSqlSession().update(map + "." + id, condition);
		return i;
	}

	/**
	 * Insert 문 사용
	 */
	@Override
	public int insert(String map, String id, Object condition) {
		int i = getSqlSession().insert(map + "." + id, condition);
		return i;
	}
	
	/**
	 * Delete 문 사용
	 */
	public int delete(String map, String id, Object condition) {
		int i = getSqlSession().delete(map + "." + id, condition);
		return i;
	}
}
